package org.jdesktop.swingx;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;

import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

import org.jdesktop.swingx.input.NewNodeMapListener;
import org.jdesktop.swingx.input.Nodes;

import vnreal.gui.menu.MapMenu;
import vnreal.map.Map;

public class PopUpMenu extends JPopupMenu {
	private JXMapViewer viewer;
	private MouseEvent evt;
	
	ActionListener actionListener = new ActionListener() {
		public void actionPerformed(ActionEvent actionEvent) {
			MapMenu.frame.setEnabled(false);
			new NewNodeMapListener(viewer, evt);
		}
	};

	ActionListener nodes = new ActionListener() {
		public void actionPerformed(ActionEvent actionEvent) {
			MapMenu.frame.setEnabled(false);
			new Nodes(viewer);
		}
	};
	
	JMenuItem anItem;

	public PopUpMenu(JXMapViewer viewer, MouseEvent evt) {
		this.evt = evt;
		this.viewer = viewer;
		anItem = new JMenuItem("Create Node");
		anItem.addActionListener(actionListener);
		add(anItem);
		
		anItem = new JMenuItem("Nodes");
		anItem.addActionListener(nodes);
		add(anItem);
	}
}